/*
 * @Author: mikey.zhaopeng
 * @Date:   2016-02-03 17:25:45
 * @Last Modified by:   mikey.zhaopeng
 * @Last Modified time: 2016-03-10 15:41:54
 */

'use strict';

define([
    './baseBean',
], function(
    BaseBean
) {
    function me() {
        BaseBean.apply(this, arguments);
        var self = this;
        this.queryMenu = function(callback, errorCallback) {
            var params = {};
            if (window.localStorage.fmpmenu) {
                if (callback) {
                    var result = JSON.parse(window.localStorage.fmpmenu);
                    callback(result, params);
                }
                return;
            }
            self.p('/user/getMenu', params, function(result) {
                window.localStorage.fmpmenu = JSON.stringify(result);
                if (callback) {
                    callback(result, params);
                }
            }, errorCallback);
        }


        /**
         * { 清空缓存 }
         *
         * @method     reset
         */
        this.reset = function() {
            localStorage.removeItem('fmpmenu')
        }
    };
    return new me();
});
